<template>
  <div v-if="data.picture"
       :class="{picture:true, active}"
       :title="data.name">
    <img :src="data.picture"/>
  </div>
  <div v-else
       :class="{text:true, active}"
       :title="data.name">
    {{ data.name }}
  </div>
</template>

<script lang="ts"
        setup>
import type {SpecValue} from '@/types/good'

defineProps<{
  data: SpecValue,
  active?: boolean
}>()
</script>

<style lang="less"
       scoped>
div {
  border: 1px solid #e4e4e4;
  margin-right: 10px;
  margin-bottom: 10px;
  cursor: pointer;

  &.active {
    border: 1px solid @xtxColor;
  }

  &.picture {
    width: 50px;
    height: 50px;
  }

  &.text {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
  }
}
</style>